package main

import (
	"fmt"
	"math"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func getTime(a, b []int) int {
	x := int(math.Abs(float64(a[0]) - float64(b[0])))
	y := int(math.Abs(float64(a[1]) - float64(b[1])))
	return min(x, y) + int(math.Abs(float64(x)-float64(y)))
}

func minTimeToVisitAllPoints(points [][]int) int {
	result := 0
	for i := 0; i < len(points)-1; i++ {
		result += getTime(points[i], points[i+1])
	}
	return result
}

func main() {
	points := [][]int{{1, 1}, {3, 4}, {-1, 0}}
	result := minTimeToVisitAllPoints(points)
	fmt.Println(result)
}
